<template>
	<view class="">
		<view class="mainpadding toububox dingwei">
			<view class="flexleft" @click="login()" v-if="!is_login">
				<image class="touxiang margin_right2" src="@/static/images/system/weidenglu.png" mode=""></image>
				<view class="">
					<view class="bigtext xiaobai fonweight ">未登录，点击登录</view>
				</view>
			</view>
			<view class="flexleft" v-if="is_login" @click="jumper('/pages_wode/gerenxx')">
				<image class="touxiang margin_right2" :src="userInfo.avatar_text" mode=""></image>
				<view class="">
					<view class="bigtext xiaobai fonweight ">{{userInfo.nickname}}</view>
					<view class="xiaobtn flexcenter margin_top1" v-if="userInfo.userlvel">{{userInfo.userlvel.name}}</view>
					<view class="xiaobtn flexcenter margin_top1" v-else>普通用户</view>
				</view>
			</view>
			<view class="qdbox flexcenter" v-if="is_login" @click="jumper('/pages_wode/qiandao')">
				<u-icon name="calendar-fill" color="#FF9341" size="24"></u-icon>
				<view class=" ">签到</view>
			</view>
			<!-- 钱包 -->
			<view class="qbbox mainpadding flexbetween radius margin_top">
				<view class="wushi flexcenter" @click="jumper('/pages_wode/yue')">
					<!-- <view class="">
						<view class="sanshier fonweight xiaobai">{{userInfo.score}}</view>·
						<view class="ershil  xiaobai margin_top2 textcenter">我的余额</view>
					</view> -->
					<view class="">
						<view class="sanshier fonweight xiaobai textcenter">{{userInfo.money}}</view>
						<view class="ershil  xiaobai margin_top2 textcenter">我的余额</view>
					</view>
				</view>
				<view class="daline"></view>
				<view class="wushi flexcenter" @click="jumper('/pages_wode/jifen')">
					<view class="">
						<view class="sanshier fonweight xiaobai textcenter">{{userInfo.score}}</view>
						<view class="ershil  xiaobai margin_top2 textcenter">联盟积分</view>
					</view>
				</view>
			</view>
			<!-- 订单 -->
			<view class="ffffff radius mainpadding margin_top">
				<view class="flexbetween" @click="jumper('/pages_wode/wodedingdan')">
					<view class="ershiba ">我的订单</view>
					<view class="flexright">
						<view class="strongtext xiaohui flexcenter margin_right2">查看全部订单</view>
						<u-icon name="arrow-right" color="#AFAFAF"></u-icon>
					</view>
				</view>
				<view class="margin_top5 flexbetween">
					<view class="ershiw flexcenter" @click="order1(1)">
						<view class="">
							<view class="ddicon">
								<image src="../static/images/system/dkh.png" mode=""></image>
							</view>
							<view class="strongtext margin_top2">待付款</view>
						</view>
					</view>
					<view class="ershiw flexcenter" @click="order1(2)">
						<view class="">
							<view class="ddicon">
								<image src="../static/images/system/dfx.png" mode=""></image>
							</view>
							<view class="strongtext margin_top2">待分享</view>
						</view>
					</view>
					<view class="ershiw flexcenter" @click="order1(3)">
						<view class="">
							<view class="ddicon">
								<image src="../static/images/system/dwc.png" mode=""></image>
							</view>
							<view class="strongtext margin_top2">待发货</view>
						</view>
					</view>
					<view class="ershiw flexcenter" @click="order1(5)">
						<view class="">
							<view class="ddicon">
								<image src="../static/images/system/ywc.png" mode=""></image>
							</view>
							<view class="strongtext margin_top2">已完成</view>
						</view>
					</view>
					<view class="ershiw flexcenter" @click="order1(6)">
						<view class="">
							<view class="ddicon">
								<image src="../static/images/system/tk.png" mode=""></image>
							</view>
							<view class="strongtext margin_top2">退款</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="mainpadding2">
			<view class="mainpadding ffffff radius">
				<view class="flexleft flex_wrap">
					<view class="ershiw flexcenter" @click="jumper('/pages_wode/huiyuan')">
						<view class="">
							<view class="nricon">
								<image class="" src="../static/images/system/hyzx.png" mode=""></image>
							</view>
							<view class="strongtext xiaohui margin_top1">会员中心</view>
						</view>
					</view>
					<view class="ershiw flexcenter" @click="jumper('/pages_wode/pingtaiq')">
						<view class="">
							<view class="nricon">
								<image class="" src="../static/images/system/yhq.png" mode=""></image>
							</view>
							<view class="strongtext xiaohui margin_top1">优惠券</view>
						</view>
					</view>
					<view class="ershiw flexcenter" @click="jumper('/pages_wode/jiudiandd')">
						<view class="">
							<view class="nricon">
								<image class="" src="../static/images/system/jddd.png" mode=""></image>
							</view>
							<view class="strongtext xiaohui margin_top1">酒店订单</view>
						</view>
					</view>
					<view class="ershiw flexcenter" @click="jumper('/pages_wode/shoucangsp')">
						<view class="">
							<view class="nricon">
								<image class="" src="../static/images/system/scsp.png" mode=""></image>
							</view>
							<view class="strongtext xiaohui margin_top1">收藏商品</view>
						</view>
					</view>
					<view class="ershiw flexcenter margin_top" @click="jumper('/pages_wode/shoucangdp')">
						<view class="">
							<view class="nricon">
								<image class="" src="../static/images/system/scdp.png" mode=""></image>
							</view>
							<view class="strongtext xiaohui margin_top1">关注店铺</view>
						</view>
					</view>
					<view class="ershiw flexcenter margin_top" @click="jumper('/pages_wode/liulanjl')">
						<view class="">
							<view class="nricon">
								<image class="" src="../static/images/system/lsjl.png" mode=""></image>
							</view>
							<view class="strongtext xiaohui margin_top1">浏览记录</view>
						</view>
					</view>
					<view class="ershiw flexcenter margin_top" @click="jumper('/pages_wode/wodemendian')">
						<view class="">
							<view class="nricon">
								<image class="" src="../static/images/system/wdmd.png" mode=""></image>
							</view>
							<view class="strongtext xiaohui margin_top1">我的门店</view>
						</view>
					</view>
					<view class="ershiw flexcenter margin_top" @click="jumper('/pages_wode/tuiguangzx')">
						<view class="">
							<view class="nricon">
								<image class="" src="../static/images/system/tgzx.png" mode=""></image>
							</view>
							<view class="strongtext xiaohui margin_top1">推广中心</view>
						</view>
					</view>
					<view class="ershiw flexcenter margin_top" @click="contactkf('admin0','1')">
						<view class="">
							<view class="nricon">
								<image class="" src="../static/images/system/lxkf.png" mode=""></image>
							</view>
							<view class="strongtext xiaohui margin_top1">联系客服</view>
						</view>
					</view>
					<view class="ershiw flexcenter margin_top" @click="jumper('/pages_wode/xitongtz')">
						<view class="">
							<view class="nricon">
								<image class="" src="../static/images/system/xttz.png" mode=""></image>
							</view>
							<view class="strongtext xiaohui margin_top1">系统通知</view>
						</view>
					</view>
					<view class="ershiw flexcenter margin_top" @click="jumper('/pages_wode/wodepingjia')">
						<view class="">
							<view class="nricon">
								<image src="../static/images/system/wdpl.png" mode=""></image>
							</view>
							<view class="strongtext xiaohui margin_top1">我的评价</view>
						</view>
					</view>
					<view class="ershiw flexcenter margin_top" @click="jumper('/pages_wode/shezhi')">
						<view class="">
							<view class="nricon">
								<image src="../static/images/system/xtsz.png" mode=""></image>
							</view>
							<view class="strongtext xiaohui margin_top1">系统设置</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				is_login: false,
				userInfo: {},
				show: false,
			}
		},
		onShow() {
			this.is_login = httpRequest.checkIsLogin();
			if (this.is_login) {
				this.init()
			}else{
				this.userInfo = {}
			}
		},
		onShareAppMessage: function(options) {
			return {
				title: '喜嘟来商业联盟',
				imageUrl: '',
				path: '/pages/index/index?invite_code=' + uni.getStorageSync("invite_code")
			}
		},
		onShareTimeline: function() {
			return {
				title: '喜嘟来商业联盟',
				imageUrl: '',
				path: '/pages/index/index?invite_code=' + uni.getStorageSync("invite_code")
			}
		},
		methods: {
			init() {
				httpRequest.request('/api/user/index', 'GET', {}).then(res => {
					this.userInfo = res.data
				})
			},
			login() {
				uni.navigateTo({
					url: "/pages/login/login"
				})
			},
			// 跳转我的订单
			order1(i) {
				if (!httpRequest.checkIsLogin()) {
					uni.navigateTo({
						url: "/pages/login/login"
					})
					return false
				}
				uni.navigateTo({
					url: '/pages_wode/wodedingdan?i=' + i
				})
			},
			// 点击聊天
			contactkf(firend_id,type){
				uni.showLoading({
					mask:true,
					title:"请稍后"
				})
				httpRequest.request('/api/user/addFriends', 'GET', {
					firend_id,
					type
				}).then(res => {
					uni.hideLoading()
					let data = {
						firend_id:firend_id,
						friend_name: "客服",
						firend_avatar_text: "@/static/images/logo.jpg"
					}
					if(res.code==1){
						uni.navigateTo({
							url:"/pages_wode/chat?msg=" + encodeURIComponent(JSON.stringify(data))
						})
					}else{
						httpRequest.toast(res.msg)
					}
				})
			},
			jumper(url) {
				if (!httpRequest.checkIsLogin()) {
					uni.navigateTo({
						url: "/pages/login/login"
					})
					return false
				}
				uni.navigateTo({
					url: url
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.nricon {
		margin: auto;
		width: 42rpx;
		height: 42rpx;

		image {
			margin: auto;
			width: 100%;
			height: 100%;
		}
	}

	.ddicon {
		width: 46rpx;
		height: 43rpx;
		margin: auto;

		image {
			margin: auto;
			width: 100%;
			height: 100%;
		}
	}

	.daline {
		width: 1rpx;
		height: 37rpx;
		background-color: rgba(255, 255, 255, 0.5);
	}

	.qbbox {
		border: 1rpx solid #FFFFFF;
		background-color: #fca075;
	}

	.qdbox {
		position: absolute;
		top: 50rpx;
		right: 0;
		font-size: 26rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		color: #FF9341;
		width: 161rpx;
		height: 59rpx;
		background: #FFFFFF;
		border-radius: 33rpx 0rpx 0rpx 33rpx;
	}

	.xiaobtn {
		width: 123rpx;
		height: 39rpx;
		background: #FFFFFF;
		border-radius: 6rpx 6rpx 6rpx 6rpx;
		font-size: 20rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		color: #FF7510;
	}

	.touxiang {
		width: 110rpx;
		height: 110rpx;
		border-radius: 50rpx;
	}

	.toububox {
		background: linear-gradient(0deg, #f8f8f8 0%, #fc8545 100%);
	}
</style>